<?php
session_start() ;

$step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 1 ;

$_SESSION['form_data'] = isset($_SESSION['form_data']) ? $_SESSION['form_data'] : Array() ;

if($_POST){
	foreach($_POST as $key => $value){
		$_SESSION['form_data'][$key] = $value ;
	}
	unset($_POST) ;
}

$themes = array(
    array('value' => 'darkness',
          'description' => 'Darkness'),
    array('value' => 'lightness',
          'description' => 'Lightness'),
    array('value' => 'smoothness',
          'description' => 'Smoothness'),
    array('value' => 'southstreet',
          'description' => 'South Street'),
    array('value' => 'redmond',
          'description' => 'Redmond'),
    array('value' => 'overcast',
          'description' => 'Overcast')
);

?>
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="../includes/jqueryui/all.css"> 
    <script src="../includes/jqueryui/js/jquery-1.5.1.min.js" type="text/javascript" ></script>
    <script src="../includes/jqueryui/js/jquery-ui-1.8.13.custom.min.js" type="text/javascript" ></script>
    <script src="../includes/jqueryui/js/jquery.cookie.js" type="text/javascript" ></script>
    <script type="text/javascript">
      function changeTheme(t){
        var val = $(t).val();
        $.cookie('jqueryui-theme',val);
        $('body').attr('class',val);
      }
      $(function(){
        $('button').button();
      });
      function test_step_1(){
        var form = $('#form_step_1')
        
        $('#submit').button({disabled : $('input[name="site_name"]').val() && $('input[name="site_url"]').val() ? false : true})
        /*
        if($('input[name="site_name"]').val() && $('input[name="site_url"]').val()){
          $('#submit').button({disabled : false})
        }else{
          $('#submit').button({disabled : true})
        }
        */
      }
      function test_step_2(){
        var form = $('#form_step_2')
        $.get('test_connection.php',form.serialize(),function(data){
          data = $.parseJSON(data)
          if('result' in data){
            $('#submit').button({disabled: data.result == 'ok' ? false : true })
          }
        })

      }
    </script>
  </head>
  <body class="<?php echo isset($_COOKIE['jqueryui-theme']) ? $_COOKIE['jqueryui-theme'] : 'redmond' ;?>" >
    <div class="wrapper">
      <div class="header ui-corner-all ui-widget-content">
        <div class="col1">
          <h1>JOC-CMS&reg; v 1.0 - Wizard Installer</h1>
        </div>
        <div class="col2">
          <label for="theme-roller">Theme-roller</label>
          <select name="theme-roller" onchange="changeTheme(this)">
            <?php foreach($themes as $theme){ ?>
            <option value="<?php echo $theme['value'] ;?>" <?php echo $_COOKIE['jqueryui-theme'] == $theme['value'] ? 'selected="selected"' : '' ;?> ><?php echo $theme['description'] ;?></option>
            <?php } ; ?>
          </select>
        </div>
      </div>
      <div class="clearfix">&nbsp;</div>
      <div class="dashboard"><?php include('steps.php') ;?></div>
      <div class="footer ui-corner-all ui-widget-content">Design based on <a href="http://www.jqueryui.com" target="_blank" title="jQueryUI CSS Framework">jQueryUI CSS Framework</a></div>
    </div>
  </body>
</html>